package com.xhl.doeverything.es.index;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.util.Date;

/**
 * 用户索引库
 *
 * @author xionghuilong
 * @date 2022/01/26 11:59
 **/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Document(indexName = "#{@userIndexName}", type = "_doc")
public class IndexUser implements Serializable {
    private static final long serialVersionUID = -2678386133560357457L;

    @Id
    private String id;

    @Field(type = FieldType.Text, analyzer="ik_max_word", searchAnalyzer="ik_max_word")
    private String name;

    @Field(type = FieldType.Keyword)
    private int age;

    @Field(type = FieldType.Keyword)
    private Integer height;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    @Field(type = FieldType.Date, format = DateFormat.custom, pattern ="yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    @Field(type = FieldType.Date, format = DateFormat.custom, pattern ="yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

}
